package cn.zymall.seckill.controller;

import cn.zymall.common.utils.response.HttpResult;
import cn.zymall.seckill.service.SecKillBusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xuxianda
 * @Description: 抢购秒杀业务控制层
 * @date 2020/8/24 17:40
 * @Copyright
 * @return
 **/
@RestController
@RequestMapping("/order")
public class SecKillBusinessController {

    @Autowired
    SecKillBusinessService secKillBusinessService;

    /**
     * 尝试下单请求处理
     * 如果下单成功会返回订单编号
     * 如果下单失败则会返回null
     *
     * @param userId       用户编号，根据用户编号获取用户信息
     * @param secKillSkuId  秒杀商品规格编号
     * @param secKillSpuId 秒杀商品编号，根据秒杀商品编号去redis中获取商品对象
     *
     * @return HttpResult 响应结果集
     */
    @PostMapping
    public HttpResult tryOrders(Integer userId, Integer secKillSkuId, Integer secKillSpuId) {
        return secKillBusinessService.orders(userId, secKillSkuId, secKillSpuId);
    }


}
